From: John Date: Fri, 26 Feb 2021 07:19:44 +0000 (+0000) Subject: build: subproject improvements: X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~5^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4383ee8693c6cfc1c11214cd294c9648fb361daa;p=babl.git build: subproject improvements: - don't expose source in dependency to avoid name clashes - add babl path variables to dependency object - add babl path variables to uninstalled pc --- diff --git a/babl/babl/meson.build b/babl/babl/meson.build new file mode 100644 index 0000000..461625a --- /dev/null +++ b/babl/babl/meson.build @@ -0,0 +1,9 @@ +# Copy the public headers here for subproject builds. + +foreach _hdr : babl_headers + configure_file( + input: _hdr, + output: '@PLAINNAME@', + copy: true, + ) +endforeach diff --git a/babl/git-version.h.in b/babl/git-version.h.in deleted file mode 100644 index a9f87e2..0000000 --- a/babl/git-version.h.in +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __GIT_VERSION_H__ -#define __GIT_VERSION_H__ - -#define BABL_GIT_VERSION "@BABL_GIT_VERSION@" - -#endif /* __GIT_VERSION_H__ */ diff --git a/babl/meson.build b/babl/meson.build index 6233678..d19210a 100644 --- a/babl/meson.build +++ b/babl/meson.build @@ -54,43 +54,14 @@ if platform_win32 babl_link_args += no_undefined endif +# sources babl_version_h = configure_file( input: 'babl-version.h.in', output: 'babl-version.h', configuration: conf, ) -# If git is available, always check if git-version.h should be -# updated. If git is not available, don't do anything if git-version.h -# already exists because then we are probably working with a tarball -# in which case the git-version.h we ship is correct. -if git_bin.found() and run_command( - git_bin, - 'rev-parse', - '--is-inside-work-tree', -).returncode() == 0 - git_version_h = vcs_tag( - input : 'git-version.h.in', - output: 'git-version.h', - replace_string: '@BABL_GIT_VERSION@', - command: [ git_bin.path(), 'describe', '--always' ], - ) - - if env_bin.found() and not meson.is_subproject() - meson.add_dist_script( - [ 'ninja', 'babl/git-version.h', ], - ) - meson.add_dist_script( - [ 'sh', '-c', ' '.join( - [ 'cp', git_version_h.full_path(), '${MESON_DIST_ROOT}/babl' ] - )] - ) - endif -else - git_version_h = files('git-version.h') -endif - -babl_sources = [ +babl_sources = files( 'babl-cache.c', 'babl-component.c', 'babl-conversion.c', @@ -123,25 +94,34 @@ babl_sources = [ 'babl-util.c', 'babl-version.c', 'babl.c', +) + [ babl_version_h, git_version_h, ] -babl_headers = [ +babl_headers = files( 'babl-introspect.h', 'babl-macros.h', 'babl-types.h', 'babl.h', +) + [ babl_version_h, ] install_headers(babl_headers, - subdir: join_paths(lib_name, 'babl') + subdir: lib_name / 'babl' ) +# copy external headers to babl subdirectory for subproject builds as +# we don't want to expose the project root folder due to potential +# name clashes. +if meson.is_subproject() + subdir('babl') +endif babl_deps = [math, thread, dl, lcms] babl_includes = [rootInclude, bablBaseInclude] +# build library babl = library( lib_name, babl_sources, @@ -155,12 +135,6 @@ babl = library( install: true, ) -libbabl_dep = declare_dependency( - include_directories: babl_includes, - link_with: babl, - dependencies: babl_deps -) - if build_gir # identity filter, so GIR doesn't choke on the Babl type # (since it has the same name as the Babl namespace) diff --git a/git-version.h.in b/git-version.h.in new file mode 100644 index 0000000..41bdefb --- /dev/null +++ b/git-version.h.in @@ -0,0 +1,6 @@ +#ifndef __BABL_GIT_VERSION_H__ +#define __BABL_GIT_VERSION_H__ + +#define BABL_GIT_VERSION "@BABL_GIT_VERSION@" + +#endif /* __BABL_GIT_VERSION_H__ */ diff --git a/meson.build b/meson.build index 62b6475..d08cb6b 100644 --- a/meson.build +++ b/meson.build @@ -30,6 +30,9 @@ buildtype = get_option('buildtype') babl_prefix = get_option('prefix') babl_libdir = join_paths(babl_prefix, get_option('libdir')) +project_build_root = meson.current_build_dir() +project_source_root = meson.current_source_dir() + ################################################################################ # Projects infos @@ -409,12 +412,46 @@ endif ################################################################################ # Configuration files +# This should not be made visible in babl_dep due to possible name clash +# when built as a sub-project. +rootInclude = include_directories('.') + # config.h configure_file( output: 'config.h', configuration: conf ) +# If git is available, always check if git-version.h should be +# updated. If git is not available, don't do anything if git-version.h +# already exists because then we are probably working with a tarball +# in which case the git-version.h we ship is correct. +if git_bin.found() and run_command( + git_bin, + 'rev-parse', + '--is-inside-work-tree', +).returncode() == 0 + git_version_h = vcs_tag( + input : 'git-version.h.in', + output: 'git-version.h', + replace_string: '@BABL_GIT_VERSION@', + command: [ git_bin.path(), 'describe', '--always' ], + ) + + if not meson.is_subproject() + meson.add_dist_script( + [ 'ninja', 'git-version.h', ], + ) + meson.add_dist_script( + [ 'sh', '-c', ' '.join( + [ 'cp', git_version_h.full_path(), '${MESON_DIST_ROOT}' ] + )] + ) + endif +else + git_version_h = files('git-version.h') +endif + ################################################################################ # Global variables @@ -428,8 +465,6 @@ gen_babl_map_file = files('gen_babl_map.py') ################################################################################ # Subdirs -rootInclude = include_directories('.') - subdir('babl') subdir('extensions') subdir('tests') @@ -456,17 +491,31 @@ endif # pkg-config file -pkgconfig.generate(babl, +pkgconfig.generate( + babl, filebase: 'babl', name: 'babl', description: 'Pixel encoding and color space conversion engine.', version: meson.project_version(), - libraries_private: [ - '-lm', + subdirs: lib_name, + uninstalled_variables: [ + 'babl_path=@0@'.format(babl_extensions_build_dir), + 'babl_libdir=@0@'.format(babl_library_build_dir), ], - subdirs: [ - lib_name, +) + +# dependency for wrap builds +babl_dep = declare_dependency( + include_directories: bablInclude, + link_with : babl, + sources: [ + babl_version_h, + is_variable('babl_gir') ? babl_gir : [] ], + variables: { + 'babl_path' : babl_extensions_build_dir, + 'babl_libdir' : babl_library_build_dir, + }, ) ################################################################################